package com.company.servicename.amqp;

import org.apache.log4j.Logger;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author fangsong.zhang
 * @date 2019年9月25日
 * Copyright zfs
 * 类说明:发送消息
 */
@Component
public class Sender {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    private static final Logger logger = Logger.getLogger(Sender.class);

    /**
     * 发送消息
     *
     * @param queueName 队列名称
     * @param msg       消息内容
     */
    public void send(String queueName, String msg) {
        logger.debug("发送消息：" + msg);
        rabbitTemplate.convertAndSend(queueName, msg);
    }
}
